{include file="public/layout" /}
<body style="overflow: auto; cursor: default; -moz-user-select: inherit;background-color:#F4F4F4; padding: 20px; ">
<div id="append_parent"></div>
<div id="ajaxwaitid"></div>
{include file="shop/left" /}
<div class="page" >
    <div class="flexigrid flexigrid2" style="min-height: 600px;">
        <div class="mDiv">
            <div class="ftitle">
               {eq name="$Think.const.CONTROLLER_NAME.'@add'|is_check_access" value="1"}
                   <div class="fbutton" style="float: none; display: none;" id="div_add">
                       <a href="{gt name="$Request.param.typeid" value="0"}{:url('ShopProduct/add', ['typeid'=>$Request.param.typeid])}{else /}javascript:quick_release('{$is_product_arctype}');{/gt}">
                           <div class="add">
                               <span><i class="layui-icon layui-icon-addition"></i>发布商品</span>
                           </div>
                       </a>
                   </div>
               {/eq}
            </div>
            <form class="navbar-form form-inline" id="searchForm" action="{:url('ShopProduct/index')}" method="get" onsubmit="layer_loading('正在处理');">
                {$searchform.hidden|default=''}
                <div class="sDiv">
                    {include file="shop_product/tags_btn" /}
                    <div class="sDiv2">
                        <input type="text" size="30" name="keywords" value="{$Request.param.keywords}" class="qsbox" placeholder="商品搜索...">
                        <input type="submit" class="btn" value="搜索">
						<i class="fa fa-search"></i>
                    </div>
                </div>
            </form>
        </div>
        
        <div class="bDiv" style="height: auto;">
            <div id="flexigrid" cellpadding="0" cellspacing="0" border="0">
                <table style="width: 100%;">
                    <thead style="background-color: #f2f2f2; line-height: 40px;">
                        <tr>
                            <th class="sign w40" axis="col0">
                                <div class="tc"><input type="checkbox" autocomplete="off" class="checkAll"></div>
                            </th>
                            <th abbr="article_title" axis="col3" class="w70">
                                <div class="tc">ID</div>
                            </th>
                            <th align="center" abbr="article_title" axis="col3" class="w60">
                                <div class="tc">商品</div>
                            </th>
                            <th align="left" abbr="article_title" axis="col3" class="">
                                <div class="ml15"></div>
                            </th>
                            <th align="left" abbr="" axis="col3" class="w80">
                                <div  class="tc">库存</div>
                            </th>
                            <th align="left" abbr="" axis="col3" class="w80">
                                <div class="tc sort_style"><a href="{:getArchivesSortUrl('users_price')}">售价&nbsp;<i {eq name='$Request.param.orderby' value='users_price'}{eq name='$Request.param.orderway' value='asc'}class="asc"{else /}class="desc"{/eq}{/eq}></i></a></div>
                            </th>
                            <th align="left" abbr="" axis="col3" class="w80">
                                <div  class="tc">浏览量</div>
                            </th>
                            <th abbr="article_time" axis="col6" class="w120">
                                <div class="tc">分类</div>
                            </th>
                            <th align="center" abbr="article_time" axis="col6" class="w50">
                                <div class="tc">推荐</div>
                            </th>
                            <th abbr="article_time" axis="col6" class="w50">
                                <div class="tc">销量</div>
                            </th>
                            <th axis="col1" class="w160">
                                <div class="tc">操作</div>
                            </th>
                            <th abbr="article_time" axis="col6" class="w60">
                                <div class="tc sort_style"><a href="{:getArchivesSortUrl('sort_order')}">排序&nbsp;<i {eq name='$Request.param.orderby' value='sort_order'}{eq name='$Request.param.orderway' value='asc'}class="asc"{else /}class="desc"{/eq}{/eq}></i></a></div>
                            </th>
                        </tr>
                    </thead>
                    <tbody>
                        {empty name="list"}
                            <tr>
                                <td class="no-data" align="center" axis="col0" colspan="50">
                                    <i class="fa fa-exclamation-circle"></i>没有符合条件的记录
                                </td>
                            </tr>
                        {else/}
                            {foreach name="list" item="vo" key="k" }
                                <tr>
                                    <td class="sign">
                                        <div class="tc w40"><input type="checkbox" autocomplete="off" name="ids[]" value="{$vo.aid}"></div>
                                    </td>

                                    <td class="sort">
                                        <div class="tc w70">{$vo.aid}</div>
                                    </td>

                                    <td class="w60">
                                        <div class="tc">
                                            <a href="{:url('ShopProduct/edit',array('id'=>$vo['aid']))}" style='{eq name="vo.is_b" value="1"} font-weight: bold; {/eq}'>
                                                <img width="60" height="60" src="{$vo.litpic}">
                                            </a>
                                        </div>
                                    </td>

                                    <td class="goods-item">
                                        <div class="fl" style="padding-left: 10px;">
                                           <div class="title">
                                                {eq name="$Think.const.CONTROLLER_NAME.'@edit'|is_check_access" value="1"}
                                                    <a href="{:url('ShopProduct/edit',array('id'=>$vo['aid']))}" style='{eq name="$vo.is_b" value="1"}font-weight: bold;{/eq}'>{$vo.title}</a>
                                                {else /}
                                                    {$vo.title}
                                                {/eq}
                                           </div>
                                        </div>
                                    </td>

                                    <td class="w80">
                                        <div class="tc">{$vo.stock_count}</div>
                                    </td>

                                    <td class="w80">
                                        <div class="tc">￥{$vo.users_price}</div>
                                    </td>

                                    <td class="w80">
                                        <div class="tc">{$vo.click}</div>
                                    </td>

                                    <td>
                                        <div class="tc w120">
                                            <a href="{:url('ShopProduct/index', array('typeid'=>$vo['typeid']))}">
                                                {$vo.typename|default='<i class="red">数据出错！</i>'}
                                            </a>
                                        </div>
                                    </td>

                                    <td class="">
                                        <div class="tc w50">
                                            {if condition="$vo['is_recom'] eq 1"}
                                                <span class="yes" {eq name="$Think.const.CONTROLLER_NAME.'@edit'|is_check_access" value="1"}onClick="changeTableVal('archives','aid','{$vo.aid}','is_recom',this);"{/eq} ><i class="fa fa-check-circle"></i>是</span>
                                            {else /}
                                                <span class="no" {eq name="$Think.const.CONTROLLER_NAME.'@edit'|is_check_access" value="1"}onClick="changeTableVal('archives','aid','{$vo.aid}','is_recom',this);"{/eq} ><i class="fa fa-ban"></i>否</span>
                                            {/if}
                                        </div>
                                    </td>

                                    <td class="w50">
                                        <div class="tc">{$vo.sales_num}</div>
                                    </td>

                                    <td align="center" class="operation">
                                        <div class="tc">
                                            {eq name="$Think.const.CONTROLLER_NAME.'@edit'|is_check_access" value="1"}
                                                <a href="{:url('ShopProduct/edit',array('id'=>$vo['aid']))}" class="btn blue">
                                                    编辑
                                                </a>
                                                <i></i>
                                            {/eq}
                                            {eq name="$Think.const.CONTROLLER_NAME.'@del'|is_check_access" value="1"}
                                                <a class="btn red" href="javascript:void(0);" data-url="{:url('ShopProduct/del')}" data-id="{$vo.aid}" {eq name='$recycle_switch' value='1'} data-deltype="del" {else /} data-deltype="pseudo" {/eq} onClick="delfun(this);">
                                                    删除
                                                </a>
                                                <i></i>
                                            {/eq}
                                            <a href="{$vo.arcurl}" target="_blank" class="btn blue">浏览</a>
                                        </div>
                                    </td>

                                    <td class="sort">
                                        <div class="w60 tc">
                                            {eq name="$Think.const.CONTROLLER_NAME.'@edit'|is_check_access" value="1"}
                                                <input type="text" onchange="changeTableVal('archives', 'aid', '{$vo.aid}', 'sort_order' ,this);" size="4" value="{$vo.sort_order}" />
                                            {else /}
                                                {$vo.sort_order}
                                            {/eq}
                                        </div>
                                    </td>
                                </tr>
                            {/foreach}
                        {/empty}
                    </tbody>
                </table>
            </div>
            <div class="iDiv" style="display: none;"></div>
        </div>
        <div class="footer-oper">
            <span class="ml15">
                <input type="checkbox" autocomplete="off" class="checkAll">
            </span>
            <div class="nav-dropup">
                <button class="layui-btn layui-btn-primary dropdown-bt">批量操作<i class="layui-icon layui-icon-up"></i></button>
                <div class="dropdown-menus" style="display:none; {if condition='0 < $pager->totalRows && ($pager->totalRows < 2 || $pager->listRows < 2)'}top:28px;bottom:unset;border-bottom:1px solid rgba(0,0,0,.15);border-top:none;min-height: 250px;{/if}">
                    {eq name="'Archives@batch_attr'|is_check_access" value="1"}
                    <a href="javascript:void(0);" onclick="batch_attr(this, 'ids', '批量新增属性');" data-url="{:url('Archives/batch_attr', ['opt'=>'add'])}">新增属性</a>
                    <a href="javascript:void(0);" onclick="batch_attr(this, 'ids', '批量删除属性');" data-url="{:url('Archives/batch_attr', ['opt'=>'del'])}">删除属性</a>
                    <hr class="layui-bg-gray">
                    {/eq}
                    {eq name="'Archives@batch_copy'|is_check_access" value="1"}
                    <a href="javascript:void(0);" onclick="func_batch_copy(this, 'ids');" data-url="{:url('Archives/batch_copy', array('typeid'=>$Request.param.typeid))}">复制商品</a>
                    {/eq}
                    {eq name="'Archives@move'|is_check_access" value="1"}
                    <a href="javascript:void(0);" onclick="func_move(this, 'ids');" data-url="{:url('Archives/move', array('typeid'=>$Request.param.typeid))}">移动商品</a>
                    {/eq}
                    {eq name="$Think.const.CONTROLLER_NAME.'@del'|is_check_access" value="1"}
                    <a href="javascript:void(0);" onclick="batch_del(this, 'ids');" data-url="{:url('ShopProduct/del')}" {eq name='$recycle_switch' value='1'} data-deltype="del" {else /} data-deltype="pseudo" {/eq}>删除商品</a>
                    {/eq}
                    {eq name="'Archives@check'|is_check_access" value="1"}
                    <hr class="layui-bg-gray">
                    <a href="javascript:void(0);" onclick="batch_check(this, 'ids');" data-url="{:url('Archives/check')}">审核商品</a>
                    <a href="javascript:void(0);" onclick="batch_check(this, 'ids');" data-url="{:url('Archives/uncheck')}">取消审核</a>
                    {/eq}
                </div>
            </div>
            {eq name="'RecycleBin@archives_index'|is_check_access" value="1"}
                {neq name='$recycle_switch' value='1'}<a href="{:url('RecycleBin/archives_index')}" class="layui-btn layui-btn-primary" title="回收站">回收站</a>{/neq}
            {/eq}
            {include file="public/page" /}
        </div>
        
    </div>
</div>

<script type="text/javascript">
    $(function(){
        try{
            if (typeof(eval('is_conceal_1649209614'))=="function" && is_conceal_1649209614()){
                $(".page").css("margin-left","");
            }else{
                $(".page").css("margin-left","98px");
            }
        }catch(e){}

        $('#div_add').show();
        
        $('input[name*=ids]').click(function(){
            if ($('input[name*=ids]').length == $('input[name*=ids]:checked').length) {
                $('.checkAll').prop('checked','checked');
            } else {
                $('.checkAll').prop('checked', false);
            }
        });
        $('input[type=checkbox].checkAll').click(function(){
            $('input[type=checkbox]').prop('checked',this.checked);
        });
    });
    $(document).ready(function() {
        // 表格行点击选中切换
        $('#flexigrid > table>tbody >tr').click(function() {
            $(this).toggleClass('trSelected');
        });

        // 点击刷新数据
        $('.fa-refresh').click(function() {
            location.href = location.href;
        });

        // 批量操作
        $(".dropdown-bt").click(function(){
            $(".dropdown-menus").slideToggle(200);
            event.stopPropagation();
        })
        $(document).click(function(){
            $(".dropdown-menus").slideUp(200);
            event.stopPropagation();
        })
    });

    var aids = '';
    function func_move(obj, name) {
        var a = [];
        var k = 0;
        aids = '';
        $('input[name^=' + name + ']').each(function(i, o) {
            if ($(o).is(':checked')) {
                a.push($(o).val());
                if (k > 0) {
                    aids += ',';
                }
                aids += $(o).val();
                k++;
            }
        })
        if (a.length == 0) {
            layer.alert('请至少选择一项', {
                icon: 2,
                title: false
            });
            return false;
        }

        var url = $(obj).attr('data-url');
        //iframe窗
        layer.open({
            type: 2,
            title: '移动文档',
            fixed: true, //不固定
            shadeClose: false,
            shade: 0.3,
            maxmin: false, //开启最大化最小化按钮
            area: ['350px', '260px'],
            content: url
        });
    }

    /**
     * 获取修改之前的内容
     */
    function get_aids() {
        return aids;
    }
</script>

<script type="text/javascript">
    /*模拟下拉选择 select */
    $('.cate-select').on('click', '.placeholder', function(e) {
        var parent = $(this).closest('.cate-select');
        if (!parent.hasClass('is-open')) {
            parent.addClass('is-open');
            $('.cate-select.is-open').not(parent).removeClass('is-open');
        } else {
            parent.removeClass('is-open');
        }
        e.stopPropagation();
    }).on('click', 'ul>li', function() {
        var parent = $(this).closest('.cate-select');
        parent.removeClass('is-open').find('.placeholder').text($(this).text());
    });

    $('body').on('click', function() {
        $('.cate-select.is-open').removeClass('is-open');
    });
</script>
{include file="public/footer" /}
